<template>
  <section :class="[!isSetPageBackground ? 'c-bg-white' : '']" class="c-flex-column">
    <cust-title-com
      v-if="item.items.isShowTitle"
      :marginSettings="item.styleParam && item.styleParam.marginSettings ? item.styleParam.marginSettings : null"
      :headLine="item.styleParam && item.styleParam.headLine ? item.styleParam.headLine : null"
      :titleName="item.title || (item.items.productType == 1 ? '商城分类' : '分类')"
      :titleDesc="item.desc"
      :showMore="item.isShowMore || item.items.isShowMore"
      :showMoreType="item.items.showMoreType" @clickMore="clickAllCategory"></cust-title-com>
    <category-item
      :itemList="item.items.prods"
      :borderRadius="item.styleParam && item.styleParam.borderRadius ? item.styleParam.borderRadius : null"
      :imageSetting="item.styleParam && item.styleParam.imageSetting ? item.styleParam.imageSetting : null"
      :marginSettings="item.styleParam && item.styleParam.marginSettings ? item.styleParam.marginSettings : null"
      :headLine="item.styleParam && item.styleParam.headLine ? item.styleParam.headLine : null"
      :productType="item.items.productType"
      :isFromM7="true"
      :itemType="item.items.orderBy"
      :showCount="item.items.count"
      :isShowMoreBottom="item.items.isShowMoreBottom"
      :isShowTitle="item.items.isShowTitle"
      :pageName="pageName"
      @clickMore="clickAllCategory">
    </category-item>
  </section>
</template>
<script>
import custTitleCom from "@/components/templates/custIndexTemp/custTitleCom.vue";
import categoryItem from "@/components/templates/categoryItem.vue";
import { appRouterChange } from "@/mixin/appRouterPush.js";
export default {
  mixins: [appRouterChange],
  components: {
    custTitleCom,
    categoryItem,
  },
  props: {
    item: {
      type: Object,
      default: () => {
        return {}
      },
    },
    pageName: {//首页INDEX 预览页PREVIEW_INDEX 微页面MICRO_PAGE
      type: String,
      default: "INDEX"
    },
  },
  data() {
    return {
      isSetPageBackground: sessionStorage.getItem("isSetPageBackground") || 0
    };
  },
  methods: {
    clickAllCategory(e) {
      if (this.pageName == 'PREVIEW_INDEX') {
        return;
      }
      if (this.item.items.productType == 1) {
        let toPath = `/mall/classification/classificationAll?cId=-1`
        this.iosAppRouteChange(toPath);
      } else {
        let toPath = "/homePage/course/courseCategory";
        this.iosAppRouteChange(toPath);
      }
    },
  },
};
</script>